version 7
#delimit;
set more off;
log using boehmke2006pa-mkdata.log, text replace;


/*	************************************************************************	*/
/*     	File Name:	boehmke2006pa-mkdata.do						*/
/*     	Date:   	May 12, 2006							*/
/*      Author: 	Frederick J. Boehmke						*/
/*      Purpose:	This file modifies timing.dta, which is the Box-Steffensmeier, 	*/
/*			Arnold and Zorn (1997) data set, downloaded directly from the 	*/
/*			ICPSR publication related archive: 				*/
/*			http://webapp.icpsr.umich.edu/cocoon/ICPSR-STUDY/01126.xml 	*/
/*			This file creates some new variables. 	 			*/
/*      Input File:	timing.dta							*/
/*      Output File:	boehmke2006pa-mkdata.dta, boehmke2006pa-mkdata.log 		*/
/*	Version:	Stata 7 or above.				 		*/
/*	************************************************************************	*/


use timing;

  summarize;


	/********************************************************/
	/* Create number of supporters and total endorsements 	*/
	/* counts by day. Then collapse the data to get a count	*/
	/* for each day and then create a running tally of net 	*/
	/* support. 						*/
	/********************************************************/


  collapse (sum) numfor=vote (count) numtot=vote, by(timing);
	
  sort timing;

  replace numfor = numfor[_n-1] + numfor[_n] if [_n] > 1;
  replace numtot = numtot[_n-1] + numtot[_n] if [_n] > 1;

  save boehmke2006pa, replace;


	/********************************************************/
	/* Return to the main data set and then merge in the  	*/
	/* runny tally of net support.			 	*/
	/********************************************************/


use timing;

  joinby timing using boehmke2006pa;

  generat numopp   = numtot - numfor;
  generat numdiff  = numfor - numopp;


	/********************************************************/
	/* Generate variables for right censoring (announce on 	*/
	/* day 463 at vote) for streg and SUDCD likelihood. 	*/
	/********************************************************/

  generat rtcensr = 0;
  replace rtcensr = 1 if timing==463;

  generat position = 1 - rtcensr;

	/********************************************************/
	/* A couple of recodes and new variables. 		*/
	/********************************************************/

  replace hhcenter = hhcenter/10;
  generat contdiff = labtpct - corptpct;

  save boehmke2006pa, replace;


label data "Unobserved factors and NAFTA position timing and content (Boehmke 2006)";

  label variable numfor		"Declared supporting positions";
  label variable numtot		"Total declared positions";
  label variable numopp		"Declared opposition positions";
  label variable numdiff	"Net declared support";
  label variable rtcensr	"Position declared on day of NAFTA vote";
  label variable position	"Position declared before day of NAFTA vote";
  label variable contdiff	"Net Labor PAC contributions";
  label variable position 	"Legislator declared a position before day of vote.";
  label variable rtcensr 	"Legislator did not declare a position before day of vote.";

  compress;

  save boehmke2006pa, replace;


log close;
clear;
exit;
